#pragma once
#include "DXAMLCommon.h"
#include "xamlnamespace.h"

#include "XamlType.h"
#include "XamlSchemaContext.h"
#include "XamlTypeNamespace.h"



class XamlXmlNamespace :
	public XamlNamespace
{
protected: 
	XamlXmlNamespace(const xshared_ptr<XamlSchemaContext> & inXamlSchemaContext, const xshared_ptr<CXString> & inXmlNamespaceUri); 
	XamlXmlNamespace(const xshared_ptr<XamlSchemaContext> & inXamlSchemaContext, const xshared_ptr<CXString> & inXmlNamespaceUri, XUINT32 runtimeIndex);
private: 
	XamlXmlNamespace();
public: 
	static HRESULT Create(const xshared_ptr<XamlSchemaContext> & inXamlSchemaContext, const xshared_ptr<CXString> & inXmlNamespaceUri, xshared_ptr<XamlXmlNamespace> & outXamlXmlNamespace);
	static HRESULT Create(const xshared_ptr<XamlSchemaContext> & inXamlSchemaContext, const xshared_ptr<CXString> & inXmlNamespaceUri, XUINT32 runtimeIndex, xshared_ptr<XamlXmlNamespace> & outXamlXmlNamespace);
	HRESULT AddTypeNamespace(const class xshared_ptr<XamlTypeNamespace> inTypeNamespace);
	virtual HRESULT get_IsResolved(XBOOL * pOut);
	virtual HRESULT GetXamlType(const xshared_ptr<CXString> & inTypeName, xshared_ptr<XamlType> & outType);
	virtual HRESULT GetDirectiveType(const xshared_ptr<CXString> & inTypeName, xshared_ptr<XamlType> & outType);
	virtual HRESULT GetDirectiveProperty(const xshared_ptr<CXString> & inPropertyName, xshared_ptr<XamlProperty> & ppOut);
	virtual XamlXmlNamespace * AsXamlXmlNamespace();
	HRESULT GetIsImplicitlyResolved(XBOOL * pbIsImplicitlyResolved);
protected: 
	virtual HRESULT get_TargetNamespaceCore(xshared_ptr<CXString> & outTargetNamespace) const;
	virtual HRESULT set_TargetNamespaceCore(const xshared_ptr<CXString> & inTargetNamespace);
private: 
	HRESULT GetXamlTypeImpl(const xshared_ptr<CXString> & inTypeName, xshared_ptr<XamlType> & outType);
	struct
	{
		XUINT32 m_bIsImplicitlyResolved:1;
		XUINT32 m_bIsImplicitlyResolvedComputed:1;
	};
protected: 
	xweak_ptr<XamlSchemaContext> m_spXamlSchemaContext;
	xshared_ptr<CXString> m_spXmlNamespaceUri;
	xvector<xshared_ptr<XamlTypeNamespace> > m_TypeNamespaceList;
	xstringmap<xshared_ptr<XamlType> > m_mapNameToXamlType;
	xstringmap<unsigned int> m_mapKnownNotFoundTypes;
};





